using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DAL;
using BLL;
using DTO;

namespace WellmeadowsHospital
{
    public partial class frmSearchPatients : DevExpress.XtraEditors.XtraUserControl
    {
        PatientBLL patientBLL = new PatientBLL();
        NextOfKinBLL nokBLL = new NextOfKinBLL();
        LocalDoctorBLL localdoctorBLL = new LocalDoctorBLL();
        AppointmentBLL appointmentBLL = new AppointmentBLL();
        public frmSearchPatients()
        {
            InitializeComponent();
            gcSearchPatientH.DataSource = patientBLL.SelectDesc();
        }

        private void txtSearchPaIdNameH_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!txtSearchPaIdNameH.Equals(""))
            {
                gcSearchPatientH.DataSource = patientBLL.Search(txtSearchPaIdNameH.Text);
            }
            else
            {
                gcSearchPatientH.DataSource = patientBLL.SelectDesc();
            }
        }

        private void txtSearchPaWithNOK_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!txtSearchPaWithNOK.Equals(""))
            {
                gcSearchPatientH.DataSource = patientBLL.SearchWithNOK(txtSearchPaWithNOK.Text);
            }
            else
            {
                gcSearchPatientH.DataSource = patientBLL.SelectDesc();
            }
        }

        private void txtSearchPaWithLocalDoctor_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!txtSearchPaWithLocalDoctor.Equals(""))
            {
                gcSearchPatientH.DataSource = patientBLL.SearchWithLocalDoctor(txtSearchPaWithLocalDoctor.Text);
            }
            else
            {
                gcSearchPatientH.DataSource = patientBLL.SelectDesc();
            }
        }

        private void gridView18_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            string key = gridView18.GetRowCellValue(gridView18.GetSelectedRows()[0], gcPatientIdInSearchPaH).ToString();
            gcNOKinSearchPaH.DataSource = nokBLL.SearchWithPatientID(key);
            gcLocalDoctorinSearchPatientH.DataSource = localdoctorBLL.SearchWithPatientID(key);
     
        }
    }
}
